
/**
 * Created by wangjiakun on 2018/6/14 0014.
 */
import React from 'react';
import { connect } from 'react-redux';

import { messages, getApprovelHistory, queryCurrencyPrecision ,getQueryUrlParam} from 'share/common';
import menuRoute from 'routes/menuRoute';

import {Form, Row, Col, Radio, Switch, Checkbox, Modal, Button, Input, Select, Divider, Spin, message, Popconfirm, Icon, Popover, Tooltip} from 'antd';
const FormItem = Form.Item;
const Option = Select.Option;
const TextArea = Input.TextArea;
const RadioGroup = Radio.Group;
import ResizeTable from 'components/resize-table'
import SubsidyRuleService from 'containers/expense-reimbursement-control/expense-standard/subsidy-rule/subsidy-rule-service';
import SlideFrame from 'components/slide-frame';
import 'styles/expense-reimbursement-control/expense-standard/subsidy-rule/subsidy-rule.scss';
import ruleUtil from 'containers/expense-reimbursement-control/expense-standard/subsidy-rule/subsidy-rule-util';
import newSubsidyRules from 'containers/expense-reimbursement-control/expense-standard/subsidy-rule/new-subsidy-rules';
import ItineraryField from 'containers/expense-reimbursement-control/expense-standard/subsidy-rule/itinerary-field';

class ListSubsidyRule extends React.Component{
  continueCopyItem = {};
  constructor(props){
    super(props);
    this.state = {
      copyModal:false,//是否弹出复制选择框
      copyTarget:{},//复制的目标对象
      isCopyRule:false,//是否是复制规则
      resetSlideFrame:true,//重置侧滑，为false时清除侧滑，为TRUE时添加新侧滑
      isEditing:false,//是否是编辑状态
      slideFrameTitle:'',//侧滑标题
      request:false,
      isUpdate:false,//是否更新侧滑基础数据
      isEditRule:false,//是否侧滑是编辑状态，否则为新建状态
      isShowSlide:false,//是否弹出侧滑
      requestBody:false,
      formOid:"",//表单OID
      btnItem:"",//添加规则按钮的对应item项
      listTypeData:[],//差补种类列表
      isHaveList:false,//是否有列表数据
      typeBaseData:"",//头部默认数据
      originData: null, //头部默认数据的初始值，便于点击取消的时候还原数据使用
      isInitBaseData:false,//是否已经设置过基础设置
      defaultRule:'',
      travelField:'',
      specialRule:'',
      itineraryField: '', //行程值列表配置
      readonly: getQueryUrlParam('readonly') === 'true',
      setOfBooksId:getQueryUrlParam('setOfBooksId'),
      columns:[{
        title:messages('setting.key1090'/*费用类型*/),
        dataIndex:'expenseTypeName',
        key:'expenseTypeName'
      },
        {
          title:messages('setting.key1091'/*规则名称*/),
          dataIndex:'name',
          key:'name'
        },
        {
          title:messages('setting.key1092'/*适用人员*/),
          dataIndex:'userGroupNames',
          render:(text, record)=>(
            text ? (
              record.userRestriction === 1007 ?
                <Popover placement="topLeft" content={messages('expense-reimbursement-control.key3',{arg1:text})/*(不包含){arg1}*/}>{messages('expense-reimbursement-control.key3',{arg1:text})/*(不包含){arg1}*/}</Popover>
                : <Popover placement="topLeft" content={text}>{text}</Popover>)
              : messages('setting.key774'/*通用*/)
          ),
          key:'userGroupNames'
        },
        {
          title:messages('setting.key1093'/*差补城市*/),
          dataIndex:'cityGroupNames',
          render:(text, record)=>(
            text ? (
                record.cityRestriction === 1007 ?
                  <Popover placement="topLeft" content={messages('expense-reimbursement-control.key3',{arg1:text})/*(不包含){arg1}*/}>{messages('expense-reimbursement-control.key3',{arg1:text})/*(不包含){arg1}*/}</Popover>
                  : <Popover placement="topLeft" content={text}>{text}</Popover>)
              : messages('setting.key774'/*通用*/)
          ),
          key:'cityGroupNames'
        },
        {
          title:messages('setting.key1094'/*币种*/),
          dataIndex:'currencyCode',
          width: 48,
          key:'currencyCode'
        },
        {
          title:messages('setting.key1095'/*标准金额*/),
          dataIndex:'standardAmount',
          align: 'right',
          render: (value, record)=>this.filterMoney(value, queryCurrencyPrecision(record.currencyCode)),
          key:'standardAmount'
        },
        {
          title:messages('setting.key1096'/*状态*/),
          dataIndex:'enabled',
          render:(text)=>(text?messages('setting.key1086'/*启用*/):messages('setting.key1087'/*禁用*/)),
          key:'enabled'
        },
        {
          title:messages('setting.key1097'/*操作*/),
          key:'action',
          render:(text,record,index) => (
            <span>
              {getQueryUrlParam('readonly') !== 'true' ? <span>
                  <a onClick={(e) => this.copyThatRule(e, record, index)}>{messages('setting.key1098'/*复制*/)}</a>
              <Divider type="vertical"/>
              <Popconfirm title={messages('setting.key1099'/*确定删除该规则?*/)}
                          onConfirm={() => this.deleteSubsidyRule(record, index)}
                          okText={messages('setting.key1100'/*确定*/)}
                          cancelText={messages('setting.key1080'/*取消*/)}>
                <a onClick={(e) => { e.stopPropagation()}}>{messages('setting.key1101'/*删除*/)}</a>
              </Popconfirm>
                </span> : '-'}
            </span>
          )
        },
      ],
      baseSubsidy:menuRoute.getRouteItem('base-subsidy','key'),
    }
  }

  componentDidMount(){
    let formOID = this.props.params.formOID;
    this.setState({formOid:formOID},() => {
      this.getListData();
      this.getTypeBaseData();
    })
  };

  //规则复制回调
  copyThatRule = (event, record, index) =>{
    event.stopPropagation();
    this.setState({isCopyRule:true,copyModal:true,btnItem:record});
  };

  //规则删除回调
  deleteSubsidyRule = (record, index) =>{
    this.setState({requestBody:true});
    SubsidyRuleService.deleteRule(record.id).then(res =>{
      this.getListData();
    }).catch(err =>{
      this.setState({requestBody:false});
      message(err.response.data.message);
    })
  };

  //编辑头部基础数据按钮回调（头部编辑回调）
  toEditTypeBase = () =>{
    this.setState({isEditing:true},()=>{
      this.props.form.resetFields();
    });
  };

  //获取规则列表
  getListData = () =>{
    this.setState({requestBody:true});
    SubsidyRuleService.getSubsidyTypeData(this.state.formOid).then(res => {
      this.setState({requestBody:false});
      if(this.continueCopyItem.formOID){//继续复制
        res.data.map(item =>{
          if(this.continueCopyItem.expenseTypeOID === item.expenseTypeOID){
            item.travelSubsidiesRuleDTOs.map(rule =>{
              if(rule.name === this.continueCopyItem.name){
                this.setState({isCopyRule:true,copyModal:true,btnItem:rule});
              }
            })
          }
        });
      }
      if(res.data && res.data.length>0){
        this.setState({listTypeData:res.data,isHaveList:true});
      }else{
        this.setState({isHaveList:false});
      }
    }).catch(err =>{
      this.setState({requestBody:false});
      message.error(err.response.data.message)
    })
  };

  //获取头部基础数据
  getTypeBaseData = () => {
    this.setState({request:true});
    SubsidyRuleService.getSubsidyTypeBaseData(this.state.formOid).then(res => {
      this.setBaseData(res, true);
    }).catch(err =>{
      this.setState({request:false});
      message.error(err.response.data.message)
    })
  };

  //设置头部基础数据
  //isFirstSet 是否初次加载，如果是的话，isUpdate不需要设置为true多次更新
  setBaseData = (res, isFirstSet) =>{
    this.setState({request:false});
    let isSet = false;
    if(res.data.tips === null){
      isSet = false;
    }else{
      isSet = true;
    }
    let deepCopy = JSON.parse(JSON.stringify(res.data));
    this.setState({
      isUpdate: !isFirstSet,
      typeBaseData:res.data,
      originData: JSON.parse(JSON.stringify(res.data)),
      isInitBaseData:isSet,
      isEditing:!isSet,
      defaultRule:deepCopy.dimensionTypes[0],
      travelField:deepCopy.dimensionTypes[1],
      specialRule:deepCopy.dimensionTypes[2],
      itineraryField: deepCopy.dimensionTypes[3]
    }, () => {
      //根据城市维度是否勾选，来决定列表上城市是否展示
      this.initColumn();
    });
  };

  initColumn = () => {
    const {defaultRule, columns} = this.state;
    let isOpenCity = true; //是否开启城市维度
    let isHasCityColumn = false; //columns里是否包含city
    let cityIndexInColumn = -1;
    columns && columns.length && columns.map((column, cityIndex) => {
      if (column.key === 'cityGroupNames') {
        isHasCityColumn = true;
        cityIndexInColumn = cityIndex;
      }
    });
    defaultRule.dimensionDetails && defaultRule.dimensionDetails.length && defaultRule.dimensionDetails.map(item => {
      if (item.code === 'ALLOWANCE_CITY') {
        isOpenCity = item.selected;
      }
    });
    if (isHasCityColumn && !isOpenCity) {
      columns.splice(cityIndexInColumn, 1);
      this.setState({columns});
    }
    if (!isHasCityColumn && isOpenCity) {
      let cityColumn = {
        title:messages('setting.key1093'/*差补城市*/),
        dataIndex:'cityGroupNames',
        render:(text)=>(text?text:messages('setting.key774'/*通用*/)),
        key:'cityGroupNames'
      };
      columns.splice(3, 0, cityColumn);
      this.setState({columns});
    }
  };

  //保存头部规则生成器的基础设置按钮回调（保存按钮回调）
  saveTypeBaseSet = (e) => {
    e.stopPropagation();
    const { typeBaseData, defaultRule, itineraryField } = this.state;
    let copyTypeBaseData = JSON.parse(JSON.stringify(typeBaseData));
    let changeStr = "";
    let isCityCheck = true;
    defaultRule.dimensionDetails && defaultRule.dimensionDetails.map((item, index) => {
      if (item.code === 'ALLOWANCE_CITY') {
        isCityCheck = item.selected;
      }
    });
    //保存头部规则生成器的基础设置前校验差补城市和自动差补是否同时开启
    if (isCityCheck && copyTypeBaseData.applicationAutoSubsidy) {
      message.error(messages('expense-reimbursement-control.key95')/*申请单自动差补功能不可与默认规则-差补城市同时启用*/);
      return;
    }
    this.props.form.validateFieldsAndScroll((err,values) => {
      if(!err){
        if(copyTypeBaseData.withTips){
          copyTypeBaseData.tips = values.tips ? values.tips : "";
        }else{
          copyTypeBaseData.tips = '';
        }
        copyTypeBaseData.dimensionTypes.map(item=>{
          item.dimensionDetails.map(detail=>{
            if(values.hasOwnProperty([detail.code])){
              if(detail.selected !== values[detail.code]){
                changeStr = changeStr + ruleUtil.changeByCode(detail.code) + ' , ';
              }
              detail.selected = values[detail.code];
            }
            //校验默认规则中差补城市的勾选是否改变
            if (detail.code === 'ALLOWANCE_CITY' && isCityCheck !== detail.selected) {
              changeStr = changeStr + ruleUtil.changeByCode(detail.code) + ' , ';
              detail.selected = isCityCheck;
            }
          })
          if(item.formFieldDetails){
            item.formFieldDetails.map(detail=>{
              if(values.hasOwnProperty([detail.fieldOID])){
                if(detail.selected !== values[detail.fieldOID]){
                  changeStr = changeStr + detail.name+ ' , ';
                }
                detail.selected = values[detail.fieldOID];
              }
            })
          }
          //处理行程值列表
          if (item.name === 'ITINERARY_FIELDS') {
            changeStr += ruleUtil.judgeIsChangeCust(item.itineraryFieldList, itineraryField.itineraryFieldList);
            item.itineraryFieldList = itineraryField.itineraryFieldList;
          }
        });

        this.processSaveStep1(copyTypeBaseData, changeStr);
      }
    })
  };

  //保存头部规则生成器的基础设置
  processSaveStep1 = (copyTypeBaseData, changeStr) => {
    const { isInitBaseData } = this.state;
    if(!isInitBaseData || !changeStr){
      this.toSave(copyTypeBaseData);
    }else{
      changeStr = changeStr.substr(0,changeStr.length - 2);
      Modal.confirm({
        title: messages('setting.key1102'/*修改后将影响当前规则，确认保存?*/),
        content: changeStr,
        onOk:() => {
          this.toSave(copyTypeBaseData);
        },
        onCancel:() => {},
      });
    }
  };

  //保存头部规则生成器的基础设置
  toSave = (typeBaseData) =>{
    this.setState({request:true});
    SubsidyRuleService.saveSubsidyHead(typeBaseData).then(res => {
      this.setBaseData(res);
      this.cancelTypeEdit();
    }).catch(err =>{
      this.setState({request:false});
      message.error(err.response.data.message);
    })
  };

  //规则生成器的基础数据编辑取消按钮回调
  //isRefresh是否还原数据，保存后不用，取消后需要还原数据
  cancelTypeEdit = (isRefresh) =>{
    const {originData} = this.state;
    this.setState({isEditing:false});
    if (isRefresh) {
      this.setBaseData({data: originData});
    }
  };

  isOpenTips = (isOpen) =>{
    const { typeBaseData } = this.state;
    typeBaseData.withTips = isOpen;
    this.setState({typeBaseData});
  };

  handleSelectSwitch = (value, key) => {
    const { typeBaseData } = this.state;
    typeBaseData[key] = value;
    this.setState({typeBaseData});
  };

  //点击添加规则按钮回调函数
  addNewRule = (item) =>{
    this.setState({isShowSlide:true,btnItem:item,slideFrameTitle:messages('setting.key1469',{arg1:item.expenseTypeName}/*新增{arg1}规则*/)});
  };

  //点击表格行进行编辑
  toEditRule = (record,index) =>{
    this.setState({
      isShowSlide:true,
      btnItem:record,
      slideFrameTitle:messages('setting.key1470',{arg1:record.expenseTypeName}/*编辑{arg1}规则*/),
      isEditRule:true
    });
  };

  //返回上一页面
  goBackBase = () => {
    this.context.router.goBack();
  };

  //关闭侧滑
  setClose = () =>{
    this.setState({isShowSlide:false});
  };

  //关闭侧滑后的事件处理
  afterBaseCloseSlide = () =>{
    this.setState({isShowSlide:false,isCopyRule:false,resetSlideFrame:false},()=>{
      this.setState({resetSlideFrame:true});
    });
  };

  /**
   * *接受从侧滑传回的消息
   * @param updated  阻止侧滑无限更新（回调此函数即阻止）
   * @param isUpdateList 是否更新规则列表
   * @param isEditRule   侧滑处于编辑状态时是否已经初始化编辑数据完毕
   * @param continueCopy  确认并复制
   */
  recivedSlideInfo = (updated, isUpdateList, isEditRule, continueCopy) =>{
    this.setState({isUpdate:false});
    if(isUpdateList){
      this.getListData();
    }
    if(isEditRule){//侧滑编辑规则是否已经初始化完毕
      this.setState({isEditRule:false});
    }
    if(continueCopy){//确认并复制
      this.continueCopyItem = continueCopy;
    }else{
      this.continueCopyItem = {};
    }
  };

  //取消复制
  cancelCopyModal  = () =>{
    this.setState({copyModal:false,isCopyRule:false});
  };

  //确定复制
  toStartCopy = () =>{
    let item = this.props.form.getFieldValue('copyWitch');
    item = this.state.listTypeData[item];
    this.setState({
      isShowSlide:true,
      isEditRule:true,
      isCopyRule:true,
      slideFrameTitle:messages('setting.key1469',{arg1:item.expenseTypeName}/*新增{arg1}规则*/),
      copyTarget:item,
      copyModal:false})
  };

  //默认规则切换checkbox
  handleCheckbox = (e) => {
    const { defaultRule } = this.state;
    defaultRule.dimensionDetails && defaultRule.dimensionDetails.map((item, index) => {
      if (item.code === 'ALLOWANCE_CITY') {
        item.selected = e.target.checked;
      }
    });
    this.setState({ defaultRule });
  };

  updateValueRuleList = (valueRuleList) => {
    const { itineraryField } = this.state;
    itineraryField.itineraryFieldList = valueRuleList;
    this.setState({itineraryField});
  };

  render(){
    const { setOfBooksId,readonly,copyModal, slideFrameTitle, isCopyRule, copyTarget, formOid, btnItem, isUpdate,
      isEditRule, resetSlideFrame, isShowSlide, isEditing, requestBody, columns, listTypeData, isHaveList,
      typeBaseData, request, isInitBaseData, defaultRule, travelField, specialRule, itineraryField } = this.state;
    const {getFieldDecorator} = this.props.form;
    const layout = {
      title:6,
      content:18
    }
    return (
      <div className="subsidy-rules">
        <Spin spinning={request}>
          <div className="title-edit">
            {
              typeBaseData.formName && <h3 className="header-title">{typeBaseData.formName}——{messages('setting.key1103'/*差补规则生成器*/)}</h3>
            }
            {
              !isEditing && !readonly&& <a onClick={this.toEditTypeBase} className="to-edit">{messages('setting.key1071'/*编辑*/)}</a>
            }
          </div>
          {
            isEditing ? <Form className="subsidy-type-list">
                <Row>
                  <Col span={layout.title} style={{maxWidth:160}}>
                    <h3>{messages('setting.key1104'/*默认规则*/)}</h3>
                  </Col>
                  <Col span={layout.content}>
                    <div className="title-edit">
                      {defaultRule.dimensionDetails && defaultRule.dimensionDetails.map((item, index)=>{
                        return (
                          <Checkbox key={item.code} disabled={item.code !== 'ALLOWANCE_CITY'} checked={item.selected}
                                    onChange={this.handleCheckbox}>
                            {ruleUtil.changeByCode(item.code,'edit')}
                          </Checkbox>
                        )
                      })}
                    </div>
                  </Col>
                </Row>
                <Row className="base-flex">
                  <Col span={layout.title} style={{maxWidth:160}}>
                    <h3>{messages('setting.key1105'/*申请单字段*/)}</h3>
                  </Col>
                  <Col span={layout.content}>
                    <div className="title-edit">
                      {travelField.dimensionDetails && travelField.dimensionDetails.map((item, index)=>{
                        return (
                          <FormItem style={{marginBottom:8}} key={index}>
                            {getFieldDecorator(item.code,{
                              valuePropName: 'checked',
                              initialValue:item.selected
                            })(
                              <Checkbox key={item.code}>{ruleUtil.changeByCode(item.code,'edit')}</Checkbox>
                            )}
                          </FormItem>
                        )
                      })}
                      {
                        travelField.formFieldDetails && travelField.formFieldDetails.map(item=>{
                          return (
                            <FormItem style={{marginBottom:8}} key={item.fieldOID}>
                              {getFieldDecorator(item.fieldOID,{
                                valuePropName: 'checked',
                                initialValue:item.selected
                              })(
                                <Checkbox key={item.fieldOID}>{item.name}</Checkbox>
                              )}
                            </FormItem>
                          )
                        })
                      }
                    </div>
                  </Col>
                </Row>
                <Row>
                  <Col span={layout.title} style={{maxWidth:160}}>
                    <h3>{messages('expense-reimbursement-control.key87')/*行程字段*/}</h3>
                  </Col>
                  <Col span={layout.content}>
                    <div className="title-edit">
                      <ItineraryField valueList={itineraryField ? itineraryField.itineraryFieldList : []} onChange={this.updateValueRuleList} />
                    </div>
                  </Col>
                </Row>
                <Row>
                  <Col span={layout.title} style={{maxWidth:160}}>
                    <h3>{messages('setting.key1106'/*特殊控制*/)}</h3>
                  </Col>
                  <Col span={layout.content} style={{marginTop:-6}}>
                    <div className="special-item">
                      {specialRule.dimensionDetails && specialRule.dimensionDetails.map((item, index)=>{
                        return (
                          <FormItem style={{marginBottom:8}} key={item.name+index}>
                            {getFieldDecorator(item.code,{
                              valuePropName: 'checked',
                              initialValue:item.selected
                            })(
                              <Checkbox key={item.code}>{ruleUtil.changeByCode(item.code,'edit')}</Checkbox>
                            )}
                          </FormItem>
                        )
                      })}
                    </div>
                  </Col>
                </Row>
                <Row>
                  <Col span={layout.title} style={{maxWidth:160}}>
                    <h3>{messages('setting.key1107'/*提示内容*/)}</h3>
                  </Col>
                  <Col span={layout.content}>
                    <div style={{display:'flex'}}>
                      <Switch checked={typeBaseData.withTips} onChange={this.isOpenTips}></Switch>
                      <span style={{color:'#ccc'}}>&nbsp;{messages('setting.key1108'/*用于在添加差补页面提醒员工相关政策，关闭后不显示*/)}</span>
                    </div>
                    {typeBaseData.withTips &&
                    <FormItem style={{marginBottom:8}}>
                      {getFieldDecorator('tips',{
                        rules:[{
                          required: true,
                          message: messages('setting.key1109'/*不能为空且不能超过1000个字符*/),
                          max:1000,
                        }],
                        initialValue:typeBaseData.tips
                      })(
                        <TextArea autosize={{minRows:7}} style={{marginTop:12,width:'62%'}} placeholder={messages('setting.key1110'/*最多输入1000个字符*/)} maxLength="1000"></TextArea>)}
                    </FormItem>
                    }
                  </Col>
                </Row>
                <Row>
                  <Col span={layout.title} style={{maxWidth:160}}>
                    <h3>{messages('expense-reimbursement-control.key1')/*差补类型默认全选*/}</h3>
                  </Col>
                  <Col span={layout.content}>
                    <div style={{display:'flex'}}>
                      <Switch checked={typeBaseData.subsidySelection} onChange={value => this.handleSelectSwitch(value, 'subsidySelection')} />
                    </div>
                  </Col>
                </Row>
                <Row>
                  <Col span={layout.title} style={{maxWidth:160}}>
                    <h3>
                      {messages('expense-reimbursement-control.key96')/*申请单自动差补*/}&nbsp;
                      <Tooltip
                        title={messages('expense-reimbursement-control.key97')/*开启申请单自动差补功能，将在填写申请单时，自动根据参与人、往返日期计算和保存差补行程；不可与默认规则-差补城市同时启用。*/}
                        placement="bottom"
                      >
                        <Icon type="info-circle-o" />
                      </Tooltip>
                    </h3>
                  </Col>
                  <Col span={layout.content}>
                    <div style={{display:'flex'}}>
                      <Switch checked={typeBaseData.applicationAutoSubsidy} onChange={value => this.handleSelectSwitch(value, 'applicationAutoSubsidy')} />
                    </div>
                  </Col>
                </Row>
              </Form>
              :ruleUtil.typeBaseHeadLayout(typeBaseData)
          }
          {
            isEditing && <Row style={{marginTop:24}}>
              <Col span={layout.title} style={{maxWidth:160}}>
              </Col>
              <Col>
                <Button type="primary" loading={request} onClick={this.saveTypeBaseSet}>{messages('setting.key1079'/*保存*/)}</Button>
                {
                  isInitBaseData && <Button style={{marginLeft:12}} onClick={() => {this.cancelTypeEdit(true)}}>{messages('setting.key1080'/*取消*/)}</Button>
                }
              </Col>
            </Row>
          }
        </Spin>
        <Divider></Divider>
        {isInitBaseData && <h3 className="header-title">{messages('setting.key1111'/*差补规则*/)}</h3>}
        {
          isInitBaseData && <Spin spinning={requestBody}>
            {
              isHaveList && isInitBaseData ? <div>
                  {
                    listTypeData.map((item,index)=>{
                      return(
                        <div key={item.expenseTypeOID}>
                          <Button disabled={!item.expenseTypeEnable||readonly} onClick={()=>this.addNewRule(item)} style={{marginBottom:18}}>{messages('setting.key1112'/*+ 新增*/)}{item.expenseTypeName}</Button>
                          <span className="expense-des">{!item.expenseTypeEnable ? messages('setting.key1631')/*该补贴类型已禁用*/ : (!!item.travelSubsidiesRuleDTOs ? '' : messages('setting.key1632')/*无差补规则*/)}</span>
                          {
                            item.travelSubsidiesRuleDTOs &&
                            <ResizeTable
                              rowKey={'id'}
                              bordered
                              columns={columns}
                              onRow={(record, index) => ({
                                onClick:() => this.toEditRule(record,index)
                              })}
                              dataSource={item.travelSubsidiesRuleDTOs}
                            />
                          }
                        </div>
                      )
                    })
                  }
                </div>:<p>{messages('setting.key1113'/*该单据下无差补费用类型*/)}</p>
            }
          </Spin>
        }
        {
          formOid && resetSlideFrame &&  <SlideFrame title={slideFrameTitle}
                                                     width={'60vw'}
                                                     content={newSubsidyRules}
                                                     show={isShowSlide}
                                                     onClose={this.setClose}
                                                     afterClose={()=>this.afterBaseCloseSlide()}
                                                     params={{
                                                       copyTarget:copyTarget,
                                                       btnItem:btnItem,
                                                       formOID:formOid,
                                                       isUpdate:isUpdate,
                                                       isEditRule:isEditRule,
                                                       isCopyRule:isCopyRule,
                                                       readonly:readonly,
                                                       setOfBooksId:setOfBooksId,
                                                       callBack:this.recivedSlideInfo
                                                     }}/>
        }
        <a onClick={this.goBackBase}><Icon type="rollback" />{messages('setting.key1114'/*返回*/)}</a>
        <Modal
          visible={copyModal}
          onOk={this.toStartCopy}
          onCancel={this.cancelCopyModal}
          okText={messages('setting.key1100'/*确定*/)}
          cancelText={messages('setting.key1080'/*取消*/)}
          title={messages('setting.key1115'/*将规则复制到...*/)}>
          <Form>
            <FormItem>
              {getFieldDecorator('copyWitch',{
                initialValue:0
              })(
                <RadioGroup>
                  {listTypeData.map((item,index)=>{
                    return (
                      <Radio key={item.expenseTypeOID+item.expenseTypeName} value={index}>{item.expenseTypeName}</Radio>
                    )
                  })}
                </RadioGroup>
              )}
            </FormItem>
          </Form>
        </Modal>
        <br/><br/>
      </div>)
  }

}

ListSubsidyRule.contextTypes = {
  router:React.PropTypes.object
}

function mapStateToProps(state) {
  return {};
}

const wrappedListSubsidyRule = Form.create()(ListSubsidyRule);

export default connect(mapStateToProps)(wrappedListSubsidyRule);
